//
//  MKDaysItem.m
//  CDatePicker
//
//  Created by Mac on 2023/12/8.
//

#import "MKDaysItem.h"
#import "MKDateModel.h"
#import "UIColor+Kyes.h"

@interface MKDaysItem ()
@property(strong,nonatomic) UILabel *num;
@end

@implementation MKDaysItem

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]){
        self.num = [[UILabel alloc]init];
        self.num.textAlignment = NSTextAlignmentCenter;
        self.num.textColor = [UIColor lightGrayColor];
        self.num.font = [UIFont boldSystemFontOfSize:16];
        self.num.frame = self.bounds;
        [self.contentView addSubview:self.num];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.num.frame = self.bounds;
}

-(void)setModel:(MKDateModel *)model{
    _model = model;
    self.num.text = [NSString stringWithFormat:@"%ld",model.day];
    
    
    if (model.today){
        self.num.backgroundColor = [UIColor hexColor:@"#EBECF3"];
    }
    
    if (model.selectDay){
        self.num.backgroundColor = [UIColor hexColor:@"#9A2924"];
    }
    
    if (!model.today && !model.selectDay){
        self.num.backgroundColor = [UIColor clearColor];
    }
}

@end
